﻿using System.Text;
using System.Data.Objects.DataClasses;
using System.Data.Metadata.Edm;
using System;
using System.Data.SqlTypes;
using System.Collections.Generic;
using System.Data;
using System.Runtime.Serialization;

namespace WA.Core.Employees.Model
{
    [DataContract]
    public abstract class BaseComplexType
    {
        public BaseComplexType()
        {
        }

        IEntityChangeTracker _complexChangeTracker = null;
        private string _rootComplexPropertyName;


        virtual public void SetComplexChangeTracker(string rootComplexPropertyName, IEntityChangeTracker complexChangeTracker)
        {
            _rootComplexPropertyName = rootComplexPropertyName;
            _complexChangeTracker = complexChangeTracker;
        }

        public void PropertyChanging(string propName)
        {
            if (_rootComplexPropertyName.StartsWith("set_"))
                _rootComplexPropertyName = _rootComplexPropertyName.Replace("set_", string.Empty);
            if (_complexChangeTracker != null)
            {
                _complexChangeTracker.EntityComplexMemberChanging(_rootComplexPropertyName, this, propName);

            }


        }

        public void PropertyChanged(string propName)
        {
            if (_complexChangeTracker != null)
            {
                _complexChangeTracker.EntityComplexMemberChanged(_rootComplexPropertyName, this, propName);
            }


        }

    }
}
